package com.example.three;

import java.util.Scanner;

public class main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String big = sc.next();
        String bigcontq = sc.nextLine();
        String bigcont = sc.nextLine();
        String[] smalls = bigcont.split("\\ ");
        int m=smalls.length;
        int[][] sum;
        sum = multiSearch(big,smalls);
        for(int i=0;i<sum.length;i++){
            for(int j=0;j<sum[i].length;j++){
                System.out.print(sum[i][j]+" ");
            }
            System.out.println();
        }
    }

    public static int[][] multiSearch(String big, String[] smalls) {
        char[] lit;
        char[] big1 = big.toCharArray();
        int n = smalls.length;
        int m = big.length();
        int[][] sum = new int[n][];
        int i=0,j=0,ave;
        while(i<n){
            if("".equals(smalls)){
                sum[0] = new int[0];
                return sum;
            }
            lit = smalls[i].toCharArray();
            int o = lit.length;
            j=0;
            String s1 = "";
            int s=0;
            while(j<m){
                int k=0;
                if(big1[j]==lit[k]&&m-j>=o){
                    ave = j;
                    while(k<o){
                        if(big1[ave]==lit[k]){
                            k++;
                            ave++;
                        }
                        else {
                            break;
                        }
                    }
                    if(k==o){
                        s1 += String.valueOf(j);
                    }
                    s++;
                }
                j++;
            }
            int len = s1.length();
            char[] sums= s1.toCharArray();
            sum[i] = new int[len];
            for(int ik =0;ik<len;ik++){
                sum[i][ik] = Character.getNumericValue(sums[ik]);
            }
            i++;
        }
        return sum;
    }
}
